#include <stdio.h>
#include <stdlib.h>


#include "sqlist.h"

int main()
{
	sqlist *list = NULL;
	datatype arr[] = {12,23,34,45,56};
	int i = 0,err = 0;
	list = sqlist_create();
	if(list == NULL)
	{
		fprintf(stderr,"sqlist_create() failed!\n");
		exit(1);
	}


	for (i=0;i<sizeof(arr)/sizeof(*arr);i++)
	{	
		err = sqlist_insert(list,0,&arr[i]);
		if (err != 0)
		{
			if(err == -1)
				fprintf(stderr,"the arr is full.\n");
			else if (err == -2)
				fprintf(stderr,"the pos you want to insert is wrong.\n");
			else
				fprintf(stderr,"Error!\n");
			exit(1);
		}
	}
	err = sqlist_deleta(list,3);
	if(err != 0)
	{
		if(err == -2)
		{
			fprintf(stderr,"the pos you want to insert is wrong.\n");	
		}else
		{
			fprintf(stderr,"Error!\n");
		}
		exit(1);
	}

	sqlist_display(list);

	sqlist *list1 = NULL;
	sqlist_create1(&list1);

	datatype arr2[] = {78,89,56,23,10};

	for (i =0;i<sizeof(arr2)/sizeof(*arr2);i++)
	{
		err = sqlist_insert(list1,0,&arr2[i]);
		if (err != 0)
		{
			if(err == -1)
				fprintf(stderr,"the arr is full.\n");
			else if (err == -2)
				fprintf(stderr,"the pos you want to insert is wrong.\n");
			else
				fprintf(stderr,"Error!\n");
			exit(1);
		}
	}
	sqlist_display(list1);

	sqlist_union(list,list1);

	sqlist_display(list);

	sqlist_destroy(list);
	sqlist_destroy(list1);
	

	exit(0);
}
